<?php
//print_r($_POST);

include "includes/functions.php";
echo db_connect();
 

$items_to_print = array();

foreach ($_POST as $key => $value)  {
	
	if (substr($key, 0, 5) == "print") { 
		$count++;
		
		
		$query = 'select * from ml_albums where album_id = "'. $value . '"';
		$result = mysql_query($query);
		$row = mysql_fetch_array($result);
		
		//echo "$query";
		//print_r($row);
		
		$artist = $row['artist'];
		$title = $row['title'];
		$cancon = $row['cancon_p']; if ($cancon == "Y") {$cancon = "Yes";}else{$cancon = "No";}
		$creation_date = substr ($row['creation_date'], 0, 10);
		$creation_user = $row['creation_user'];
		$review = $row['freetext'];
		$label = $row['label'];
		
		$section_id = $row['section_id'];
			$queryD='SELECT * FROM ml_sections WHERE section_id = "' . $section_id . '"';
			$resultD= mysql_query($queryD);
			$rowD= mysql_fetch_array($resultD, MYSQL_NUM);
			$section_id_db = $rowD[0];
			$section_label_db = $rowD[1];
			$section_image_tag_db = $rowD[2];
		
		$items_to_print[] = "
		<table width='100%' cellpad='12' bgcolor='white'>
		<tr valign='top'>
		<td class='lg'>Artist:<b>$artist</b> <br>
		Album: <b>$title</b> <br>
		Label: <b>$label</b> <br>
		Major Genre: <b>$section_label_db</b> <br>
		Cancon: <b>$cancon</b><br>
		Added to Library: <b>$creation_date</b><br>Profanity In Tracks (do not play before 9pm)
		<table width='100%' height='20' border='1' bordercolor='#000000' cellpadding='0' cellspacing='0' ><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr></table>
		</td>
		<td rowspan='2'><img src=\"images/spacer.gif\" width='1' />
		</tr>
		<tr height='175' >
<td class='lg' valign='top'>Review by <b>$creation_user:</b><br>$review
		</td>
		</tr>
		</table>
		";
	
	}
}

if ($count > 6) DIE ("<html><script language='JavaScript'>alert('Too many selected. Please select reviews to print in groups of 6 or less.'),history.go(-1)</script></html>");
if (!$count) DIE ("<html><script language='JavaScript'>alert('No albums selected. Use the checkboxes on the right side of the list to select albums.'),history.go(-1)</script></html>");

//print_r ($items_to_print);

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style >
body {
font-family: Arial, Helvetica, sans-serif;
	font-size: 8px;
	color: #000000;
}
.lg {
font-family: Arial, Helvetica, sans-serif;
	font-size: 10px;
	color: #000000;
}

</style>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Album Reviews</title>
</head>

<body leftmargin="80" topmargin="60" marginwidth="0" marginheight="0">
<table width="750" border="1" bordercolor="#000000" cellpadding="20" cellspacing="0" bgcolor="#eeeeee">
  <tr>
    <td width = "375"><?php echo $items_to_print[0]; ?></td>
    <td width = "375"><?php echo $items_to_print[1]; ?></td>
  </tr>
  <?php if ($count > 2) { ?>
  <tr>
    <td width = "375"><?php echo $items_to_print[2]; ?></td>
    <td width = "375"><?php echo $items_to_print[3]; ?></td>
  </tr>
  <?php } if ($count > 4) { ?>
  
  <tr>
    <td width = "375"><?php echo $items_to_print[4]; ?></td>
    <td width = "375"><?php echo $items_to_print[5]; ?></td>
  </tr>
  
  <?php }  ?>
  
</table>
</body>
</html>
